package com.yang.springcloud.controller;

import com.yang.springcloud.pojo.Dept;
import com.yang.springcloud.service.DeptClientServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 请求的消费者
 * 消费者不应该有service层
 *
 * @author shiwen
 * @date 2020/10/12
 */
@RestController
public class DeptConsumerController {

    @Autowired
    private DeptClientServer deptClientServer;

    @RequestMapping("/consumer/dept/add")
    public boolean add(Dept dept) {
        return this.deptClientServer.addDepe(dept);
    }

    @RequestMapping("/consumer/dept/getById/{id}")
    public Dept get(@PathVariable("id") long id) {
        return this.deptClientServer.queryById(id);
    }

    @RequestMapping("/consumer/dept/queryAll")
    public List<Dept> queryAll() {
        return this.deptClientServer.queryAll();
    }

}